package ca.eloas.judging.model;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.Ref;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Index;
import com.googlecode.objectify.annotation.Load;
import com.googlecode.objectify.annotation.Parent;
import com.sun.tools.hat.internal.server.RefsByTypeQuery;

import java.beans.IndexedPropertyChangeEvent;

/**
 * @author JP
 */
@Entity
public class ScoreObject extends DBObjectImpl<ScoreObject> implements Score {

    private int score;
    private String comments;

    @Parent
    private Key<TeamObject> team;

    @Index
    @Load
    private  Ref<JudgeObject> judge;


    protected ScoreObject() {
    }

    public ScoreObject(TeamObject teamObject, JudgeObject j, int score, String comment) {

        this.score = score;
        this.comments = comment;
        this.team = teamObject.getKey();
        this.judge = Ref.create(j.getKey());
    }

    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    public JudgeObject getJudge() {
        return judge.get();
    }

    protected Key<TeamObject> getParentKey() {
        return team;
    }
}
